package com.eshanren.ext.base;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

import java.util.Enumeration;


/**
 * 拦截器基类
 *
 * @author WWF
 */
public abstract class BaseInterceptor implements Interceptor {


    /**
     * 跳转url*
     */
    protected static final String REDIRECT_URL = "redirectURL";

    /**
     * 结果
     */
    protected static final String CODE = "code";
    /**
     * 说明
     */
    protected static final String MESSAGE = "message";

    @Override
    public void intercept(Invocation invocation) {
    }


    /**
     * 清空Controller 中返回的信息
     *
     * @param invocation
     */
    public void clearAttrs(Invocation invocation) {
        //先清空原先的值
        Enumeration<String> attrs = invocation.getController().getAttrNames();
        while (attrs.hasMoreElements()) {
            String attr = attrs.nextElement();
            invocation.getController().removeAttr(attr);
        }
    }
}
